<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="/js/jquery-3.2.1.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
		<form action="list" method="post">
		植物名字:<input type="text" name="name" value="${plant.name }">
			<input type="submit" value="查询">
			<a href="toadd"><input type="button" value="添加"></a>
			<input type="button" value="批量删除" onclick="del()">
			<table>
				<tr>
					<td>序号</td>
					<td>植物名称</td>
					<td>描述</td>
					<td>类别</td>
					<td>操作</td>
				</tr>
				<c:forEach items="${pg.list}" var="a">
				<tr>
					<td><input type="checkbox" name="ck" value="${a.id }"></td>
					<td>${a.id }</td>
					<td>${a.name }</td>
					<td>${a.describes }</td>
					<td>${a.tname }</td>
					<td><a href="toupdate?id=${a.id }"><input type="button" value="修改"></a></td>
				</tr>
				</c:forEach>
				<jsp:include page="/js/page.jsp"></jsp:include>
			</table>
		</form>
</body>

<script type="text/javascript">

function del(){
	var ids="";
	$("[name='ck']:checked").each(function(){
		ids+=","+$(this).val();
		
	})
	ids=ids.substring(1);
	$.post("del",{ids:ids},function(obj){
		if(confirm("确定要删除吗"+ids)){
			alert("删除成功");
			location.href="list";
		}else{
			alert("删除失败");
		}
		
	})
}





</script>
</html>